Yahoo: Fix parsing when final price in series is null#68
Merged
blais merged 1 commit intobeancount:masterfrom Dec 31, 2023
Merged
Yahoo: Fix parsing when final price in series is null#68blais merged 1 commit intobeancount:masterfrom
blais merged 1 commit intobeancount:masterfrom
Conversation
Contributor
Author
|
Duplicate fix in code as #66 - this PR includes a test for this case. |
|
@blais I've been experiencing this issue recently, and this fix helped me. Any chance to get it merged? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For a mutual fund for today, Yahoo API returns a null for the most recent price entry in the price array. A timestamps is present, but the price values are null:
e.g.:
[9.6899995803833,9.710000038146973,9.6899995803833,null]The current code anticipates the response potentially returning a price earlier than the date queried, so this fix just filters out the null entries and returns what's left, even if earlier than the queried date.
e.g. from:
https://query1.finance.yahoo.com/v8/finance/chart/FTIHX?period1=1645650000&period2=1646082000&interval=1d&lang=en-US&corsDomain=finance.yahoo.com&.tsrc=finance
returns:
{"chart":{"result":[{"meta":{"currency":"USD","symbol":"FTIHX","exchangeName":"NAS","instrumentType":"MUTUALFUND","firstTradeDate":1466083800,"regularMarketTime":1646053576,"gmtoffset":-18000,"timezone":"EST","exchangeTimezoneName":"America/New_York","regularMarketPrice":13.63,"chartPreviousClose":13.56,"priceHint":2,"currentTradingPeriod":{"pre":{"timezone":"EST","start":1646038800,"end":1646058600,"gmtoffset":-18000},"regular":{"timezone":"EST","start":1646058600,"end":1646082000,"gmtoffset":-18000},"post":{"timezone":"EST","start":1646082000,"end":1646096400,"gmtoffset":-18000}},"dataGranularity":"1d","range":"","validRanges":["1mo","3mo","6mo","ytd","1y","2y","5y","10y","max"]}, "timestamp":[1645626600,1645713000,1645799400,1646058600], "indicators":{"quote":[{ "close":[13.5600004196167,13.34000015258789,13.630000114440918,null], "low":[13.5600004196167,13.34000015258789,13.630000114440918,null], "open":[13.5600004196167,13.34000015258789,13.630000114440918,null], "high":[13.5600004196167,13.34000015258789,13.630000114440918,null] ,"volume":[0,0,0,null]}],"adjclose":[{"adjclose":[13.5600004196167,13.34000015258789,13.630000114440918,null]}]}}],"error":null}}